# -*- coding: utf-8 -*-
# @Time    : 2019/11/8 15:28
# @Author  : Jinwei
# @File    : py_app.py


class driver_fengzhuang():
    def __init__(self, driver):
        self.driver = driver

    def find_ele(self, fang, lujing):
        # if fang == 'xpath':
        #     se = self.driver.find_element_by_xpath(lujing)
        # else:
        #     raise NameError('no element,please send xpath')
        # return se
        return self.driver.find_element_by_xpath(lujing)

    def ins(self, path):  # 安装app
        self.driver.install_app(path)

    def rem(self, baoming):  # 卸载app
        self.driver.remove_app(baoming)

    def rem_ios(self, bundleId):  # ios
        self.driver.remove_app(bundleId)

    def close(self):  # 关闭app
        self.driver.close_app()

    def reset(self):  # 重置app
        self.driver.reset()

    def hide_keyb(self):  # 隐藏键盘
        self.driver.hide_keyboard()

    def send_keyevent(self, event):  # 只有安卓有
        self.driver.keyevent(event=event)

    def sned_press_keycode(self, keycode):  # 安卓有
        self.driver.press_keycode(keycode=keycode)

    def long_press_keycode(self, keycode):  # 长按发送
        self.driver.long_press_keycode(keycode)

    def current_activity(self):
        activity = self.driver.current_activity()
        return activity

    def wait_activity(self, activity, times, interval=1):
        self.driver.wait_activity(activity, time=times, interval=1)

    def run_back(self, second):
        self.driver.background_app(seconds=second)

    def is_app_installed(self, baoming):  # ios需要buildid
        self.driver.is_app_installed(baoming)

    def launch_app(self):  # 启动app
        self.driver.launch_app()

    def start_acti(self, app_package, app_activity):
        self.driver.start_activity(app_package, app_activity)

    def ios_lock(self, locktime):
        self.driver.lock(locktime)

    def yaoshouji(self):
        self.driver.shake()

    def open_tongzhi(self):  # 安卓api 18以上
        self.driver.open_notifications()

    def renturn_network(self):  # 返回网络
        network_type = self.driver.network_connection
        return network_type
